package com.siemens.operation;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class PropertiesConfig {
	private static List<ConfigEntity> group = new ArrayList<ConfigEntity>();
	private static List<ConfigEntity> im = new ArrayList<ConfigEntity>();
	private static List<ConfigEntity> presence = new ArrayList<ConfigEntity>();
	static{
		String proName = null;
		FileInputStream fis = null;
		Properties pro = new Properties();
		/*if (System.getProperty("file.separator").equals("/")) {
			proName = System.getProperty("catalina_home")
					+ "/conf/config.properties";
		} else {
			proName = System.getenv("CATALINA_HOME")
					+ "/conf/config.properties";
		}*/
		//proName = "/opt/jakarta-tomcat-6.0.13/conf/config.properties";
		// proName = System.getenv("JBOSS_HOME")
		// + " rver/all/conf configure.properties";
		try {
			/*proName = "/export/home/jakarta-tomcat-6.0.13/conf/config.properties";
			
			fis = new FileInputStream(new File(proName));
			pro.load(fis);
			fis.close();*/
			pro = ResourcesUtils.getResourceAsProperties("config.properties");
			group.add(new ConfigEntity("业务名称",pro.getProperty("groupServiceName").trim()));
			group.add(new ConfigEntity("Group业务平台支持的最大群组数目",pro.getProperty("maxNbrGroup").trim()));
			group.add(new ConfigEntity("Group业务平台支持的最大企业群组数目",pro.getProperty("maxNbrcGroup").trim()));
			group.add(new ConfigEntity("Group业务平台支持的最大自发群组数目",pro.getProperty("maxNbruGroup").trim()));
			group.add(new ConfigEntity("Group业务平台群组最大用户数",pro.getProperty("maxUserPerGroup").trim()));
			group.add(new ConfigEntity("Group业务平台最大活跃会话数",pro.getProperty("maxNbrActiveSession").trim()));
			group.add(new ConfigEntity("Group业务平台最大请求处理能力",pro.getProperty("maxNbrRequestProcess").trim()));
			group.add(new ConfigEntity("用户信息的最大存储数",pro.getProperty("maxUserInfo").trim()));
			im.add(new ConfigEntity("业务名称",pro.getProperty("imServiceName").trim()));
			im.add(new ConfigEntity("IM业务平台最大支持的登记用户数",pro.getProperty("maxNbrRegisteredUser").trim()));
			im.add(new ConfigEntity("IM业务平台支持的最大活跃SIP对话数",pro.getProperty("maxNbrActiveSipSession").trim()));
			im.add(new ConfigEntity("IM业务平台转发或发送消息的最大数",pro.getProperty("maxNbrSendMsg").trim()));
			im.add(new ConfigEntity("IM业务平台转发或发送单条消息的最大长度",pro.getProperty("maxLengthSendMsg").trim()));
			im.add(new ConfigEntity("IM业务平台存储转发消息空间大小",pro.getProperty("maxSpaceSendMsg").trim()));
			im.add(new ConfigEntity("IM业务平台发送文件的最大吞吐量",pro.getProperty("maxFIleSendMsg").trim()));
			im.add(new ConfigEntity("IM业务平台最大存储的离线消息数",pro.getProperty("maxNbrOfflineUserMsg").trim()));
			im.add(new ConfigEntity("IM业务平台离线消息存储时长",pro.getProperty("maxDurationOfflineUserMsg").trim()));
			im.add(new ConfigEntity("IM业务系统广播有效期",pro.getProperty("maxDurationBroadMsg").trim()));
			presence.add(new ConfigEntity("业务名称",pro.getProperty("presenceServiceName").trim()));
			presence.add(new ConfigEntity("Presence最大用户数",pro.getProperty("maxNbrUser").trim()));
			presence.add(new ConfigEntity("Presence最大服务请求处理数",pro.getProperty("maxNbrReqProcess").trim()));
			presence.add(new ConfigEntity("Presence最大服务通知发送数",pro.getProperty("maxNbrNotifySend").trim()));
			presence.add(new ConfigEntity("最大支持订阅用户状态信息的数目",pro.getProperty("maxSubUserNum").trim()));
			
			
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public static List<ConfigEntity> getGroup(){
		return PropertiesConfig.group;
	}
	
	public static List<ConfigEntity> getIm(){
		return PropertiesConfig.im;
	}
	
	
	public static List<ConfigEntity> getPresence(){
		return PropertiesConfig.presence;
	}
	
	public static void main(String...strings){
		List<ConfigEntity> gp = PropertiesConfig.getGroup();
		List<ConfigEntity> im = PropertiesConfig.getIm();
		List<ConfigEntity> pr = PropertiesConfig.getPresence();
		
		for(ConfigEntity c:gp){
			System.out.println(c);
		}
		
		System.out.println("==========================");
		for(ConfigEntity c:im){
			System.out.println(c);
		}
		
		System.out.println("==========================");
		for(ConfigEntity c:pr){
			System.out.println(c);
		}
	}
	
}
